package cn.edu.hqu.cst.android.ex2;

import android.content.Intent;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class   MainActivity extends Activity implements OnClickListener {
    TextView show;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        show=findViewById(R.id.ShowText);

        Button b1=findViewById(R.id.b1);
        b1.setOnClickListener(this);

        Button b3=findViewById(R.id.b3);
        b3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                show.setText("匿名内部类按钮被点击了！");
                Log.d("event","匿名内部类事件监听");
            }
        });

        Button b4=findViewById(R.id.b4);
        b4.setOnClickListener(view->{
            show.setText("LAMBDA表达式按钮被点击了！");
            Log.d("event","LAMBDA方式事件监听");

        });

        Button b2=findViewById(R.id.b2);
        b2.setOnClickListener(new nListener());

        Button b5=findViewById(R.id.b5);
        b5.setOnClickListener(new OnClick() {
            public void onClick(View view) {
                show.setText("外部类按钮被点击了！");
                Log.d("event","外部类事件监听");
            }
        });

        Button b7 = findViewById(R.id.b7);
        b7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent= new Intent(MainActivity.this,System_info.class);
                startActivities(new Intent[]{intent});
            }
        });

        Button b8 = findViewById(R.id.b8);
        b8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent= new Intent(MainActivity.this,DialogTest.class);
                startActivities(new Intent[]{intent});
            }
        });
    }

    @Override
    public void onClick(View v) {
        show.setText("ACTIVITY按钮被点击了！");
        Log.d("event","ACTIVITY事件监听");
    };
    class nListener implements OnClickListener {
        @Override
        public void onClick(View view) {
            show.setText("内部类按钮被点击了！");
            Log.d("event","内部类事件监听");
        }
    }
    public void jtq(View v){
        show.setText("绑定到标签按钮被点击了！");
        Log.d("event","绑定到标签事件监听");
    }
}